package com.fhz.shop.api;

import androidx.lifecycle.LiveData;

import com.fhz.shop.callback.ApiResponse;
import com.fhz.shop.entity.Category;
import com.fhz.shop.entity.GoodsInfo;
import com.fhz.shop.entity.GoodsInfoLocal;
import com.fhz.shop.entity.HUser;
import com.fhz.shop.entity.PageHelper;
import com.fhz.shop.entity.UserCart;

import java.util.List;

import retrofit2.http.Body;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.Path;
import retrofit2.http.Query;

/**
 * 时间:2023/8/17
 *
 * @author Mr.Feng
 * 简述: TODO
 */
public interface ServiceApi {

//    @GET("banner/select")
//    LiveData<ApiResponse<Banner>> getBanner(@Query("type") int type, @Query("page") int page, @Query("pageSize") int pageSize);


    @GET("goods/select/{page}/{pageSize}")
    LiveData<ApiResponse<PageHelper<GoodsInfoLocal>>> getGoodsInfo(@Path("page") int page, @Path("pageSize") int pageSize);

//
//    @POST("/user/register")
//    LiveData<ApiResponse<HUser>> register(@Body HUser hUser);

    @GET("category/getType")
    LiveData<ApiResponse<List<Category>>> getCategory(@Query("type") int type);


    @POST("/user/login")
    @FormUrlEncoded
    LiveData<ApiResponse<HUser>> login(@Field("nickname") String nickname,@Field("password") String password);


    @GET("qiniu/token")
    LiveData<ApiResponse<String>> getQiNiuToken();


    @POST("/user/update/headImg")
    @FormUrlEncoded
    LiveData<ApiResponse<String>> updateHeadImage(@Field("nickname") String nickname,@Field("headImg") String headImg);

    @GET("/goods/info/{id}")
    LiveData<ApiResponse<GoodsInfoLocal>> getGoodsDetails(@Path("id") int id);


    @POST("/cart/add")
    LiveData<ApiResponse<UserCart>> addCart(@Body UserCart userCart);

    @GET("/cart/getAllByUserId")
    LiveData<ApiResponse<List<UserCart>>> getCartList(@Query("userId") int userId);


    @GET("/cart/update/num")
    LiveData<ApiResponse<UserCart>> updateNum(@Query("cartId") int cartId ,@Query("num") int num);


}
